<?php
/**
 * Created by : PhpStorm
 * @date: 2023/3/26 13:01
 */

namespace ClassLibrary;

/**
 * Trait ClTrait
 * @package ClassLibrary
 * @date 2023/3/26 13:02
 */
trait ClTrait {

    /**
     * 实例对象
     * @var array
     * @author SongKeJing qq:597481334 mobile:159-5107-8050
     * @date 2022/4/17 21:59
     */
    private static $ins = [];

    /**
     * 构造函数
     * ServiceBase constructor.
     */
    public function __construct() {
        static::_initialize();
    }

    /**
     * 初始化
     * @author SongKeJing qq:597481334 mobile:159-5107-8050
     * @date 2022/9/24 9:39
     */
    protected function _initialize() {

    }

    /**
     * 实例化
     * @return mixed|static
     * @author SongKeJing qq:597481334 mobile:159-5107-8050
     * @date 2022/4/17 22:02
     */
    public static function instance() {
        //依据当前类解决冲突问题
        $static_class_name = static::class;
        if (!isset(self::$ins[$static_class_name])) {
            self::$ins[$static_class_name] = new static();
        }
        return self::$ins[$static_class_name];
    }

}